<script>
  import { count, person, message } from "./store.js";
  let messageInput = "";
  let nameInput = "";
  const addCount = () => {
    count.update((n) => n + 1);
  };
  const reduceCount = () => {
    count.update((n) => n - 1);
  };
  const changeMessage = () => {
    message.set(messageInput);
  };
  const changePersonName = () => {
    person.update((p) => {
      p.name = nameInput;
      return p;
    });
  };
</script>

<main>
  <button on:click={addCount}>+</button>
  <button on:click={reduceCount}>-</button>
  <p>
    <input bind:value={messageInput} /><button on:click={changeMessage}
      >修改message</button
    >
  </p>
  <p>
    <input bind:value={nameInput} /><button on:click={changePersonName}
      >修改person.name</button
    >
  </p>
</main>
